package com.IODemo.properties;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @Author milian
 * @Date 2021/7/28 0028 10:31
 * properties配置文件(prop.properties)
 */
public class propertiesDemo {
    public static void main(String[] args) throws IOException {
        Properties prop = new Properties();
        prop.put("张三","12");
        prop.put("张","14");
        prop.put("张w","13");
//        Set<Object> keys = prop.keySet();
//        for (Object key : keys) {
//            Object value = prop.get(key);
//            System.out.println(value);
//        }
//        Set<Map.Entry<Object, Object>> entries = prop.entrySet();
//        for (Map.Entry<Object, Object> entry : entries) {
//            Object key = entry.getKey();
//            Object value = entry.getValue();
//            System.out.println(key+","+value);
//        }
        FileWriter fw = new FileWriter("H:\\test\\test.txt");
        prop.store(fw,"");
        fw.close();
        FileReader fr = new FileReader("H:\\test\\test.txt");
        prop.load(fr);
        System.out.println(prop);

    }
}
